<template>
  <div class="zqty_bodys" style="padding-top:20px;border:0px solid blue;" :style="{'height':(divAutoHeight-180)+'px','width':(divAutoWidth - 150)+'px'}" >
    <div  style="border:0px solid green;"  :style="{'height':(divAutoHeight-180)+'px','width':(divAutoWidth-170)+'px','margin-left':'20px'}" >
     <!-- 查询 -->
    <el-popover placement="bottom-start"  trigger="click">
      <el-form :inline="true" :model="search" label-width="75px" class="search-panle">
        <el-form-item label="客户档案号" ><el-input v-model="search.cardid"></el-input></el-form-item>
        <el-form-item label="客户姓名"><el-input v-model="search.name"></el-input></el-form-item>
        <el-form-item label="创建时间" ><el-date-picker v-model="search.time" type="daterange"  range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" align="right"></el-date-picker></el-form-item>
        <el-button type="primary" @click="searchData">提交</el-button>
      </el-form>
      <el-button slot="reference" type="primary">查询</el-button>
    </el-popover>
    <!-- 表格 -->
    <el-tabs v-model="mainActiveName" @tab-click="syschRecodeStatus">
      <el-tab-pane label="待体检" name="0">
        <div class="divTop" style="border:0px solid red;" :style="{'height':(divAutoHeight-270)+'px','overflow-y':'auto','overflow-x':'hidden'}">

           <ul>
              <li v-for="item in tableData" class="showDataLi">
                <div class="showDataTop">
                  <div class="showDataTopLeft">
                    <img
                      v-if="item.providerInfo.photo"
                      :src="'data:image/png;base64,'+ item.bodyCheckPhoto"
                      class="showDataImg"
                    />
                  </div>
                  <div class="showDataTopCenter">
                    <div style="width:99%;height:30px;">
                      <div
                        style="font-size:16px;font-weight:bolder;float:left;"
                      >{{item.providerNoName}}</div>
                      <div
                        style="font-size:13px;color:gray;float:left;margin-left:5px;margin-top:3px;"
                      >{{item.providerInfo.sex === '1'? '男':'女'}}&nbsp;{{item.providerInfo.age}}岁</div>
                    </div>
                    <div style="width:99%;height:70px;font-size:13px;color:gray;">
                      <div>登记号：{{item.registerNo}}</div>
                      <div style="margin-top:3px;">病案号：{{item.providerInfo.cardId}}</div>
                      <div style="margin-top:3px;">体检护士：{{item.bodyCheckWorkerName}}</div>
                      <div style="margin-top:3px;">体检时间：{{timestampToTime(item.bodyEndTime,'yy-mm-dd hh:mm:ss')}}</div>
                    </div>
                  </div>
    

                  <div class="showDataTopRight">
                    <div   v-if="item.recodeStatus == 1"  class="statusGreen">
                      已体检
                    </div>
                    <div   v-if="item.recodeStatus != 1 " class="statusGreen">
                      待体检
                    </div>
                  </div>


                </div>
                <div class="showDataFoot" @click="updateDialog(item)">编辑</div>

                <!-- <div class="right">
                      <el-form>
                        <el-form-item label="客户:">{{item.providerNoName}}</el-form-item>
                        <el-form-item label="护士:">{{item.bodyCheckWorkerName}}</el-form-item>
                        <el-form-item label="客户:">{{item.providerNoName}}</el-form-item>
                      </el-form>
                </div>-->
              </li>
            </ul>




          <!-- <el-row :gutter="24">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" v-for="item in tableData" :key="item.id">
              <el-card shadow="hover"  class="showDataLi">
                <div class="showDataTop">
                  <div class="showDataTopLeft">
                    <el-avatar v-if="item.bodyCheckPhoto" :size="80" :src="'data:image/png;base64,'+ item.bodyCheckPhoto"></el-avatar>
                    <el-avatar v-else :size="80" src="https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png"></el-avatar>
                  </div>
                  <div class="showDataTopCenter">
                    <div style="width:99%;height:30px;">
                        <div style="font-size:16px;font-weight:bolder;float:left;">
                            {{item.providerNoName}}
                        </div>
                        <div  style="font-size:13px;color:gray;float:left;margin-left:5px;margin-top:3px;">
                            {{item.providerInfo.sex === '1'? '男':'女'}}&nbsp;{{item.providerInfo.age}}岁
                        </div>
                    </div>
                    <div style="width:99%;height:70px;font-size:13px;color:gray;">
                      <div>登记号：{{item.registerNo}}</div>
                      <div style="margin-top:3px;">病案号：{{item.providerInfo.cardId}}</div>
                      <div style="margin-top:3px;">体检护士：{{item.bodyCheckWorkerName}}</div>
                      <div style="margin-top:3px;">体检时间：{{item.bodyEndTime}}</div>
                    </div>
                  </div>
                  <div class="showDataTopRight">
                    <div   v-if="item.recodeStatus == 1"  class="checkBody-tag bg-success statusGreen">
                      已体检
                    </div>
                    <div   v-if="item.recodeStatus != 1 " class="checkBody-tag bg-success statusGreen" style="">
                      待体检
                    </div>
                  </div>

                </div>
                <div class="showDataFoot" >
                <el-row :gutter="24">
                    <el-col :span="24">
                      <div @click="updateDialog(item)" class="optionBtn">编辑</div>
                  </el-col>
                </el-row>
                </div>
              </el-card>
            </el-col>
           </el-row> -->
        </div>
        <div class="divfooter">
           <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[10, 15,20, 25,30,50, 100]" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"></el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="已体检" name="1">
        <div class="divTop" style="border:0px solid red;" :style="{'height':(divAutoHeight-270)+'px','overflow-y':'auto','overflow-x':'hidden'}">

  <ul>
              <li v-for="item in tableData" class="showDataLi">
                <div class="showDataTop">
                  <div class="showDataTopLeft">
                    <img
                      v-if="item.providerInfo.photo"
                      :src="'data:image/png;base64,'+ item.bodyCheckPhoto"
                      class="showDataImg"
                    />
                  </div>
                  <div class="showDataTopCenter">
                    <div style="width:99%;height:30px;">
                      <div
                        style="font-size:16px;font-weight:bolder;float:left;"
                      >{{item.providerNoName}}</div>
                      <div
                        style="font-size:13px;color:gray;float:left;margin-left:5px;margin-top:3px;"
                      >{{item.providerInfo.sex === '1'? '男':'女'}}&nbsp;{{item.providerInfo.age}}岁</div>
                    </div>
                    <div style="width:99%;height:70px;font-size:13px;color:gray;">
                      <div>登记号：{{item.registerNo}}</div>
                      <div style="margin-top:3px;">病案号：{{item.providerInfo.cardId}}</div>
                      <div style="margin-top:3px;">体检护士：{{item.bodyCheckWorkerName}}</div>
                      <div style="margin-top:3px;">体检时间：{{timestampToTime(item.bodyEndTime,'yy-mm-dd hh:mm:ss')}}</div>
                    </div>
                  </div>
    

                  <div class="showDataTopRight">
                    <div   v-if="item.recodeStatus == 1"  class="statusGreen">
                      已体检
                    </div>
                    <div   v-if="item.recodeStatus != 1 " class="statusGreen">
                      待体检
                    </div>
                  </div>


                </div>
                <div class="showDataFoot" @click="updateDialog(item)">编辑</div>

                <!-- <div class="right">
                      <el-form>
                        <el-form-item label="客户:">{{item.providerNoName}}</el-form-item>
                        <el-form-item label="护士:">{{item.bodyCheckWorkerName}}</el-form-item>
                        <el-form-item label="客户:">{{item.providerNoName}}</el-form-item>
                      </el-form>
                </div>-->
              </li>
            </ul>



          <!-- <el-row :gutter="24">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" v-for="item in tableData" :key="item.id" class="showDataTop">
              <el-card shadow="hover"  class="showDataLi">
                  <div class="showDataTop">
                    <div class="showDataTopLeft">
                      <el-avatar v-if="item.bodyCheckPhoto" :size="80" :src="'data:image/png;base64,'+ item.bodyCheckPhoto"></el-avatar>
                      <el-avatar v-else :size="80" src="https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png"></el-avatar>
                    </div>
                    <div class="showDataTopCenter">
                      <div style="width:99%;height:30px;">
                          <div style="font-size:16px;font-weight:bolder;float:left;">
                              {{item.providerNoName}}
                          </div>
                          <div  style="font-size:13px;color:gray;float:left;margin-left:5px;margin-top:3px;">
                              {{item.providerInfo.sex === '1'? '男':'女'}}&nbsp;{{item.providerInfo.age}}岁
                          </div>
                      </div>
                      <div style="width:99%;height:70px;font-size:13px;color:gray;">
                        <div>登记号：{{item.registerNo}}</div>
                        <div style="margin-top:3px;">病案号：{{item.providerInfo.cardId}}</div>
                        <div style="margin-top:3px;">体检护士：{{item.bodyCheckWorkerName}}</div>
                        <div style="margin-top:3px;">体检时间：{{item.bodyEndTime}}</div>
                      </div>
                    </div>
                    <div class="showDataTopRight">
                      <div   v-if="item.recodeStatus == 1"  class="checkBody-tag bg-success statusGreen">
                        已体检
                      </div>
                      <div   v-if="item.recodeStatus != 1 " class="checkBody-tag bg-success statusGreen" style="">
                        待体检
                      </div>
                    </div>
                  </div>
                  <div class="showDataFoot" >
                  <el-row :gutter="24">
                      <el-col :span="24">
                        <div @click="updateDialog(item)" class="optionBtn">编辑</div>
                    </el-col>
                  </el-row>
                  </div>
                </el-card>
            </el-col>
          </el-row> -->
       </div> 
       <div class="divfooter">
          <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[10, 15,20, 25,30,50, 100]" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"></el-pagination>       
       </div>       
      </el-tab-pane>
      
    </el-tabs>
    <!-- 详情 -->
    <el-dialog :title="dialog.title" :visible.sync="dialog.isShow" width="99%" top="60px" :close-on-click-modal="false"  :before-close="closeDialogHandler" class="dialog-form" v-dialogDrag>
      <div :style="{'height':(tableHeight-90)+'px','overflow-y':'auto'}">
         <el-tabs v-model="dialogActiveName" @tab-click="syschRecodeStatus">
            <el-tab-pane label="基本信息" name="2">
              <!-- 浆员基本信息 -->
              <pulpworkInfo v-bind:cardid="dialogList.providerNo"></pulpworkInfo>
            </el-tab-pane>
            <el-tab-pane label="生命体征" name="3">
              <el-form :inline="true" :model="dialogList" :rules="dialogRules" ref="dialogRules" label-width="120px" class="demo-ruleForm">
                      <el-form-item label="体重/kg" prop="weight"><el-input v-model="dialogList.weight"></el-input></el-form-item>
                      <el-form-item label="体温/℃" prop="animalHeat"><el-input v-model="dialogList.animalHeat"></el-input></el-form-item>
                      <el-form-item label="脉搏/B/M" prop="pulse"><el-input v-model="dialogList.pulse"></el-input></el-form-item>
                      <br/>
                      <el-form-item label="血压/KPa">
                          <el-row style="width: 480px;">
                            <el-col :span="25"><el-form-item prop="lowBlood"><el-input  v-model="dialogList.lowBlood"></el-input></el-form-item></el-col>
                            <el-col class="line" :span="1">-</el-col>
                            <el-col :span="25"><el-form-item prop="highBlood"><el-input  v-model="dialogList.highBlood"></el-input></el-form-item></el-col>
                          </el-row>
                      </el-form-item>
                      <el-form-item label="体检护士"><el-input v-model="dialogList.createNurseName" disabled></el-input></el-form-item>
              </el-form>
              <div style="width:100%;height:50px;text-align:right;line-height:50px;">
                <el-button type="primary" @click="submitDialog" >提交</el-button>
              </div>
            </el-tab-pane>
            <el-tab-pane label="脉波压力检测" name="4">
              <el-form :inline="true" ref='stressM' :model="dialogForStress" label-width="100px" class="demo-ruleForm" :rules="chestRules">

                <!-- 
                      dialogForStress:{
                      id:null,//Id
                      bid:null,// 体检ID
                      filePath:null,//图片路径，可存储多个，中间用$$隔开
                      checkDate:null,//检测时间
                      checkUser:null,//检测护士
                      meanHeartRate:null,//平均心率
                      abnormalHeartRate:null,//异常心率
                      bloodStage:null,//血管阶段
                      stressScore:null,//压力评分
                      checkUserName:null,//上传护士
                      images:null,              //图片内容

                      },
                 -->
                <el-form-item label="压力评分" prop="stressScore" ><el-input v-model="dialogForStress.stressScore"></el-input></el-form-item>
                <el-form-item label="平均心率" prop="meanHeartRate" ><el-input v-model="dialogForStress.meanHeartRate"></el-input></el-form-item>
                <el-form-item label="异常心率" prop="abnormalHeartRate" ><el-input v-model="dialogForStress.abnormalHeartRate"></el-input></el-form-item>
                <el-form-item label="血管阶段" prop="bloodStage" ><el-input v-model="dialogForStress.bloodStage"></el-input></el-form-item>
                <el-form-item label="检测护士"><el-input v-model="dialogForStress.checkUserName" disabled></el-input></el-form-item>
                <el-table-column>
                  <template></template>
                    <div style="width:100%;height:50px;text-align:left;line-height:50px;position :relative;top:41px;left:190px;z-index:9999; ">
                      <el-button type="primary" @click="submitDialogForStress" >提交</el-button>
                    </div>
                </el-table-column>
                <el-form-item label="附件上传" prop="photo" style="display:block;">
                <template slot="label">检测图片</template>
                <div :span="19" class="avatar">
                  <el-upload
                        class="upload-demo"
                        ref="uploadImageBox"
                        :action="dialogForStress.actionUrl"
                        :on-success="updateImageSize"
                        list-type="picture">
                        <el-button size="small" type="primary">点击上传</el-button>
                        <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                  </el-upload>
                      <div v-for="item in fileList" style="width:1060px;height:1520px;">
                        <img :src="item.url" style="width:1060px;height:1520px;">
                      </div>
                </div>
              </el-form-item>
              </el-form>
            
              <!-- <h3 class="dialog-plate-title"><span>结果上传</span></h3> -->

             <!-- <el-button type="primary" @click="insertHOtherCheck('6')">新增</el-button>
               <el-table :data="tableDataForStressM" stripe border class="company-table">
                  <el-table-column fixed type="index" label="*" sortable align="center" min-width="40"></el-table-column>
                  <el-table-column prop="stressVal" label="压力值" sortable min-width="100"></el-table-column>
                  <el-table-column prop="MHRate" label="平均心率" sortable min-width="100"></el-table-column>
                  <el-table-column prop="AHRate" label="异常心率" sortable min-width="100"></el-table-column>
                  <el-table-column prop="VPhase" label="血管阶段" sortable min-width="100"></el-table-column>
                  <el-table-column prop="checkDate" label="检测日期" sortable min-width="100">
                    <template slot-scope="scope">
                      {{timestampToTime(scope.row.checkDate,'yyyy-mm-dd')}}
                    </template>
                  </el-table-column>
                  <el-table-column prop="uploadDate" label="上传日期" sortable min-width="130">
                    <template slot-scope="scope">
                      {{timestampToTime(scope.row.uploadDate,'yyyy-mm-dd hh:mm')}}
                    </template>
                  </el-table-column>
                  <el-table-column prop="uploadUserName" label="上传人" sortable min-width="200"></el-table-column>
                  <el-table-column fixed="right" label="操作" align="center" min-width="75">
                      <template slot-scope="scope">
                          <el-button  @click="insertUpdateCheck('stress',scope.row)" type="text" size="small">详情</el-button>
                      </template>         
                  </el-table-column>
              </el-table> -->

            </el-tab-pane>
            <el-tab-pane label="微循环检测" name="5">
              <microcirculation v-bind:bid="dialogList.bodyRecodeId" v-bind:cVal="dialogForStress.cVal"></microcirculation>
            </el-tab-pane> 
         </el-tabs>
      </div>

    </el-dialog> 
    <el-dialog :title="dialogForUp.title" :visible.sync="dialogForUp.isShow" width="100%" :height="divAutoHeight+'px'" top="60px" center :close-on-clcick-modal="false" class="dialog-form">
      <div :style="{'height':(tableHeight-90)+'px','overflow-y':'auto'}">
        <el-form :inline="true" ref='checkForm' :model="dialogForUp" label-width="100px" class="demo-ruleForm" :rules="chestRules">
          <span v-if="dialogForUp.type==='stress'">
          <el-form-item label="压力值" prop="stressVal" ><el-input v-model="dialogForUp.checkUnit"></el-input></el-form-item>
          <el-form-item label="平均心率" prop="MHRate" ><el-input v-model="dialogForUp.checkRemark"></el-input></el-form-item>
          <el-form-item label="异常心率" prop="AHRate" ><el-input v-model="dialogForUp.checkRemark"></el-input></el-form-item>
          <el-form-item label="血管阶段" prop="VPhase" ><el-input v-model="dialogForUp.checkRemark"></el-input></el-form-item>
          <el-form-item label="就诊日期" prop="checkDate" ><el-date-picker type="date" v-model="dialogForUp.checkDate" placeholder="选择日期"></el-date-picker></el-form-item>
          <el-form-item label="病例记录人"><el-input v-model="dialogForUp.uploadUserName"></el-input></el-form-item>
          </span> 
          <span v-if="dialogForUp.type==='history'">
          <el-form-item label="检查单位" prop="checkUnit" ><el-input v-model="dialogForUp.checkUnit"></el-input></el-form-item>
          <el-form-item label="诊断结果" prop="checkRemark" ><el-input v-model="dialogForUp.checkRemark"></el-input></el-form-item>
          <el-form-item label="就诊日期" prop="checkDate" ><el-date-picker type="date" v-model="dialogForUp.checkDate" placeholder="选择日期"></el-date-picker></el-form-item>
          <el-form-item label="病例记录人"><el-input v-model="dialogForUp.uploadUserName"></el-input></el-form-item>
          </span>  
          <span v-if="dialogForUp.type==='blood'">
          <el-form-item label="白细胞计数" prop="wbc" ><el-input v-model="dialogForUp.wbc"></el-input></el-form-item>
          <el-form-item label="血小板" prop="platelet" ><el-input v-model="dialogForUp.platelet"></el-input></el-form-item>
          <el-form-item label="HCT" prop="hct" ><el-input v-model="dialogForUp.hct"></el-input></el-form-item>
          <el-form-item label="甘油三脂" prop="triglyceride" ><el-input v-model="dialogForUp.triglyceride"></el-input></el-form-item>
          <el-form-item label="LP" prop="lp" ><el-input v-model="dialogForUp.lp"></el-input></el-form-item>
          <el-form-item label="SOD" prop="sod" ><el-input v-model="dialogForUp.sod"></el-input></el-form-item>
          <el-form-item label="MDA" prop="mda" ><el-input v-model="dialogForUp.mda"></el-input></el-form-item>
          <el-form-item label="低密脂蛋白" prop="ldl" ><el-input v-model="dialogForUp.ldl"></el-input></el-form-item>
          <el-form-item label="胆固醇" prop="cholesterol" ><el-input v-model="dialogForUp.cholesterol"></el-input></el-form-item>
          <el-form-item label="检测日期" prop="checkDate" ><el-date-picker type="date" v-model="dialogForUp.checkDate" placeholder="选择日期"></el-date-picker></el-form-item>
          <el-form-item label="上传人"><el-input v-model="dialogForUp.uploadUserName" disabled></el-input></el-form-item>
          </span>
          <span v-if="dialogForUp.type==='ct'">
          <el-form-item label="检测日期" prop="checkDate" ><el-date-picker type="date" v-model="dialogForUp.checkDate" placeholder="选择日期"></el-date-picker></el-form-item>
          <el-form-item label="上传人"><el-input v-model="dialogForUp.uploadUserName" disabled></el-input></el-form-item>
          </span>
          <span v-if="dialogForUp.type==='mt'">
          <el-form-item label="检测日期" prop="checkDate" ><el-date-picker type="date" v-model="dialogForUp.checkDate" placeholder="选择日期"></el-date-picker></el-form-item>
          <el-form-item label="上传人"><el-input v-model="dialogForUp.uploadUserName" disabled></el-input></el-form-item>
          </span>
          <span v-if="dialogForUp.type==='ots'">
           <el-form-item label="检测日期" prop="checkDate" ><el-date-picker type="date" v-model="dialogForUp.checkDate" placeholder="选择日期"></el-date-picker></el-form-item>
          <el-form-item label="上传人"><el-input v-model="dialogForUp.uploadUserName" disabled></el-input></el-form-item>
          </span>
          <el-form-item label="附件上传" prop="photo" style="display:block;">
            <template slot="label">病例</template>
            <div :span="19" class="avatar">
              <el-upload
                    class="upload-demo"
                    ref="uploadImageBox1"
                    :action="dialogForUp.actionUrl"
                    :on-success="updateImageSize"
                    list-type="picture">
                    <el-button size="small" type="primary">点击上传</el-button>
                    <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
              </el-upload>
                   <div v-for="item in fileList" style="width:1060px;height:1520px;">
                     <img :src="item.url" style="width:1060px;height:1520px;">
                   </div>
            </div>
          </el-form-item>
        </el-form>       
      </div>
      <div slot="footer" style="text-align: right;">
          <el-button type="primary" @click="submitChestDialog">提交</el-button>
      </div> 
    </el-dialog>
  </div>
  </div>
</template>
<script>
import api from 'plugins/axios/api.js';
import regx from 'plugins/regx.js';
import pulpworkInfo from 'views/operationManage/components/pulpworkInfo.vue';
import microcirculation from 'views/operationManage/components/bodyCheck/microcirculation.vue';
// import historicalCase from 'views/operationManage/components/bodyCheck/historicalCase.vue';
export default {
  components:{
      pulpworkInfo,
      microcirculation,
  },
  data(){
    return {
      fileList: [],
      dialogActiveName:'2',
      search:{
        cardid:'',
        name:'',
        time:[],
        recodeStatus:0,
      },
      tableData:[],
      tableDataForStressM:[],
      dictorData:{},
      chestRules:{
        result:[ {required: true, message: '请选择是否合格', trigger: 'blur'}],
        hospital:[{required: true, message: '请输入检查单位', trigger: 'blur'}],
        doctor:[{required: true, message: '请输入检查医生', trigger: 'blur'}],
        remark:[{required: true, message: '请输入检查备注', trigger: 'blur'}],
        validDate:[{required: true, message: '请输入有效日期', trigger: 'blur'}],
        photo:[{required: true, message: '请上传病例照片', trigger: 'blur'}],
      },
      dialogForUp:{
        title:'',
        isShow:false,
        type:'',
        actionUrl:'/uploadCheckImage/{id}/{type}',
        //血液检查
        bloodId:null,                      //记录Id
        wbc: null,                         //白细胞计数
        platelet:null,                     //血小板
        hct:null,                          //HCT
        filePath:null,                     //图片路径（数据库字段）
        images:[],                         //图片路径（视图层路径）
        checkDate: new Date(),             //检查日期 
        uploadDate: new Date(),            //上传日期 
        uploadUser: null,                  //上传人ID 
        uploadUserName:localStorage.getItem('ms_username'), //上传人姓名 
        providerIdCard: "513902199201146037", //对应的用户身份证
        triglyceride: null,                //甘油三脂 
        lp: null,                          //LP
        sod: 1,                            //SOD
        mda: null,                         //MDA 
        ldl: null,                         //低密脂蛋白 
        cholesterol: null,                 //胆固醇 
        //血液循环字段完毕
        //历史病例
        historyId:null,                    //记录Id
        checkRemark:null,                  //检测结果
        checkUnit:null,                    //检测单位
        ctId:null,
        mtId:null,
        otsId:null,
      },
      dialogForStress:{
        actionUrl:'/uploadCheckImage/{id}/{type}',
        id:null,//Id
        bid:null,// 体检ID
        filePath:null,//图片路径，可存储多个，中间用$$隔开
        checkDate:null,//检测时间
        checkUser:null,//检测护士
        meanHeartRate:null,//平均心率
        abnormalHeartRate:null,//异常心率
        bloodStage:null,//血管阶段
        stressScore:null,//压力评分
        checkUserName:localStorage.getItem('ms_username'),//上传护士
        images:null,              //图片内容
        cVal:false,
      },
      pagination:{
        currentPage:1,
        pageSize:10,
        total:0
      },
      dialogList:{
        createNurseName:localStorage.getItem('ms_username'),
      },
      appendixUrl:"/api/adscm/filesystem/abc",
      dialogRules:{
        weight: [
            { required: true, message: '请输入体重...', trigger: 'blur' },
            {  type: 'number', message: '体重不能高于150Kg，低于45Kg', trigger: 'blur', validator:regx.validateWeight},
          ],
          animalHeat: [
            { required: true, message: '请输入体温...', trigger: 'blur' },
            { type: 'number', message: '体温不能高于37.2 ℃，低于36.3 ℃', trigger: 'blur',validator:regx.validateAnimalHeat }
          ],
          pulse: [
            { required: true, message: '请输入脉搏...', trigger: 'blur' },
            { type: 'number', message: '脉搏不能高于100/B/M，低于60/B/M', trigger: 'blur',validator:regx.validatePulse},
          ],
          lowBlood: [
            { required: true, message: '请输入低血压...', trigger: 'blur' },
            { type: 'number', message: '低压不能高于8/KPa，低于12/KPa', trigger: 'blur',validator:regx.validateLowBlood},
          ],
          highBlood: [
            { required: true, message: '请输入高血压...', trigger: 'blur' },
            { type: 'number', message: '高压不能高于12/KPa，低于20/KPa', trigger: 'blur',validator:regx.validateHighBlood},
          ],
      },
      mainActiveName:'0',
      dialog:{
        title:'',
        isShow:false
      }
    }
  },
  created(){
    this.getData();
  },
  computed:{
    tableHeight() {
      return this.$store.state.clientHeight - 184;
    },
    divAutoHeight() {
      return this.$store.state.clientHeight;
    },
    divAutoWidth() {
      return this.$store.state.clientWidth - 100;
    },
    autoHeight() {
      return this.$store.state.clientHeight / 2 - 55;
    },
    autoWidth() {
      return this.$store.state.clientWidth - 55;
    }
  },
  methods:{
    closeDialogHandler(){
      let self = this;
      self.dialog.isShow = false;
      self.fileList=[];
      self.dialogActiveName='2';
    },
    updateImageSize(response, file, fileList){
      let self = this;
      let imageObj={name:file.name,url:'data:image/png;base64,'+response.content};
      self.fileList.push(imageObj);
    },
    insertHOtherCheck(type){
      let self = this;
       self.tableDataForStressM = [];
      self.tableDataForStressM.push({stressVal:1});
      // api.insertHOtherCheck(type,self.dialogForUp.idCard).then(res=>{
      //   self.$message("新增成功!");
      //   self.queryOtherChecks(Number(type));
      // });
    },
    //打开上传dialog弹窗
    insertUpdateCheck(type,row){
      let self = this;
      //self.copyRowDataToFormData(type,row);
      switch (type) {
        case 'stress': self.dialogForUp.isShow = true;self.dialogForUp.type=type;self.dialogForUp.actionUrl=api.idTypeImgUpload(row.id,6);self.queryOtherChecksDetail(row.id,6); break;  //脉波压力检测
        default: break;
      }
    },
    //数据回显
    copyRowDataToFormData(type,row){
      let self = this;
          self.dialogForUp.id = row.id;
          self.dialogForUp.checkDate = row.checkDate;
          self.dialogForUp.uploadDate = row.uploadDate;
          self.dialogForUp.uploadUser = row.uploadUser;
          self.dialogForUp.uploadUserName = row.uploadUserName;
          self.dialogForUp.providerIdCard = row.providerIdCard;
      switch (type) {
        case 'blood':
          self.dialogForUp.bloodId = row.id;
          self.dialogForUp.wbc = row.wbc;
          self.dialogForUp.platelet = row.platelet;
          self.dialogForUp.hct = row.hct;
          self.dialogForUp.lp = row.lp;
          self.dialogForUp.sod = row.sod;
          self.dialogForUp.mda = row.mda;
          self.dialogForUp.ldl = row.ldl;
          self.dialogForUp.cholesterol = row.cholesterol;
           break;
        case 'ct':
          self.dialogForUp.ctId = row.id;
          
           break;
        case 'mt': 
          self.dialogForUp.mtId = row.id;
       
           break;
        case 'ots':
          self.dialogForUp.otsId = row.id;
           break;
        case 'history':
          self.dialogForUp.historyId = row.id;
          self.dialogForUp.checkUnit = row.checkUnit;
          self.dialogForUp.checkRemark = row.checkRemark;
          break;
        case 'stress':
          self.dialogForUp.historyId = row.id;
          self.dialogForUp.checkUnit = row.checkUnit;
          self.dialogForUp.checkRemark = row.checkRemark;
          break;     
        default:
          break;
      }

    },
    queryOtherChecks(type){
      let self = this;
      api.queryOtherChecks(type,self.dialogForUp.idCard).then(res=>{
        switch (type) {
          case 6: self.tableDataForStressM =res.content;break;
          default:
            break;
        }
      });
    },
    submitChestDialog(){},
    syschRecodeStatus(ins){
      let self = this;
      self.dialogList.createNurseName=localStorage.getItem('ms_username');
      switch (ins.name) {
        case '1':
          self.search.recodeStatus=1;
          self.getData();
          break;
        case '0':
          self.search.recodeStatus=0;
          self.getData();
          break;  
        case '3':
          self.dialogForUp.type ='smtz';  //生命体征
          self.queryOtherChecks(6);
          break; 
        case '4':
          // self.dialogForUp.type ='stress';
          self.queryBloodvessel();
          break;
        case '5':
          // self.dialogForUp.type ='stress';
          if(self.dialogForStress.cVal){
            self.dialogForStress.cVal=false;
          }else{
            self.dialogForStress.cVal=true;
          }
          break;   
        default:
          break;
      }
    },
    getData(){//获取体检记录列表
      let self = this;
      self.loading=true;
      let list={
          name:self.search.name,
          cardid:self.search.cardid,
          recodeTime:self.timestampToTime(new Date,'yy-mm-dd'),
          pageSize:self.pagination.pageSize,
          recodeStatus:self.search.recodeStatus,
          currentPage:self.pagination.currentPage
      }
      if(self.search.time.length>0){
        list.bigCreateTime = self.timestampToTime( self.search.time[0],'yy-mm-dd');
        list.lessCreateTime=self.timestampToTime( self.search.time[1],'yy-mm-dd');
      }
      api.bodyCheckTime(list).then(res=>{
          self.tableData=res.content.items;
          self.loading=false;
          self.pagination.total = res.content.total;
      },error=>{
            self.loading=false;
      })

    },
    /**新版页面数据功能补全 __by:zf */
    getDoctorData(){//获取医生列表
      let self = this;
      self.loading=true;
      api.getDoctorData({id:4}).then(res=>{
        self.dictorData = res.content;
        self.loading=false;
        /**↓ 此处联动 self.updateDialog 方法 Number转换 如果该血源没有医生，则默认所有医生列表中的第一个 ↓*/
        if(self.dialogList.bodyCheckWorker==0){
          self.dialogList.bodyCheckWorker=self.dictorData[0].id;
        }
      },error=>{
            self.loading=false;
      })
    },
    queryBloodvessel(){
      let self = this;
      api.queryBloodvessel(self.dialogList.bodyRecodeId).then(res=>{
          self.$refs.uploadImageBox.clearFiles();
          self.fileList=[];
          self.copyQueryDataToFormData(res.content);
          let images = res.content.images; 
          images.forEach(element => {
            self.fileList.push({name:Math.random(1000),url:element});
          });
      });
    },
    copyQueryDataToFormData(row){
      let self = this;
      if(row!=null&&row!=undefined){
        self.dialogForStress.id = row.id;
        self.dialogForStress.actionUrl=api.idImgUploadForStress(self.dialogForStress.id);
        self.dialogForStress.bid = row.bid;
        self.dialogForStress.filePath = row.filePath;
        self.dialogForStress.checkDate = row.checkDate;
        self.dialogForStress.checkUser = row.checkUser;
        self.dialogForStress.meanHeartRate = row.meanHeartRate;
        self.dialogForStress.abnormalHeartRate = row.abnormalHeartRate;
        self.dialogForStress.bloodStage = row.bloodStage;
        self.dialogForStress.stressScore = row.stressScore;
        self.dialogForStress.checkUserName = row.checkUserName==null?localStorage.getItem('ms_username'):row.checkUserName;
        self.dialogForStress.images = row.images;
        //         bid:null,// 体检ID
        // filePath:null,//图片路径，可存储多个，中间用$$隔开
        // checkDate:null,//检测时间
        // checkUser:null,//检测护士
        // meanHeartRate:null,//平均心率
        // abnormalHeartRate:null,//异常心率
        // bloodStage:null,//血管阶段
        // stressScore:null,//压力评分
        // checkUserName:localStorage.getItem('ms_username'),//上传护士
        // images:null,              //图片内容
      }

    },
    submitDialogForStress(){
      let self = this;
      api.updateBloodvessel(self.dialogForStress).then(res=>{
        self.$message("成功");
        self.queryBloodvessel();
      });
      ///adscm/application/bodyCheckOther/uploadCheckImage/{id}   //上传图片
      ///adscm/application/bodyCheckOther/updateBloodvessel       //保存
      ///adscm/application/bodyCheckOther/queryBloodvessel/{bodyCheckId} //查询
    },
    submitDialog(){/** 更新后台信息*/
      let self = this;
      self.loading=true;
      let params = {
          weight:self.dialogList.weight,
          animalHeat:self.dialogList.animalHeat,
          pulse:self.dialogList.pulse,
          lowBlood:self.dialogList.lowBlood,
          highBlood:self.dialogList.highBlood,
          bodyRecodeId:self.dialogList.bodyRecodeId,
      }
      api.addUpdataCheckBodyInfo(params).then(res=>{
        self.loading=false;
        self.dialog.isShow=false;
        self.$message.success('信息编辑成功！');
        self.getData();
        self.dialog1.isShow = false;
      },error=>{
            self.loading=false;
      })

     },
    searchData(){/**搜索提交 */
      this.pagination.currentPage=1;
      this.getData();
    },
    updateDialog(row){/**点击编辑*/
      let self = this;
      self.dialog.title = '详情信息';
      self.dialog.isShow = true;
      self.dialogList = row;
      self.dialogForStress.id = row.bodyRecodeId;
      self.dialogForUp.idCard = row.idNo;
      self.dialogList.bodyCheckWorker=Number(self.dialogList.bodyCheckWorker);
      self.getDoctorData();
    },
    handleSizeChange(size){/**改变分页条数 */
      this.pagination.currentPage=1;
      this.pagination.pageSize = size;
      this.getData();
    },
    handleCurrentChange(current){/**改变分页页码 */
       this.pagination.currentPage=current;
      this.getData();
    },
    beforeAvatarUpload(file){/**图标上传前尺寸大小判断 */
      const isJPG = file.type.substr(0,5) === 'image';
      const isLt1M = file.size / 1024 / 1024 < 1;
      if (!isJPG) {
          this.$message.error('只能上传图片!');
      }
      if (!isLt1M) {
          this.$message.error('上传头像图片大小不能超过 1MB!');
      }
      return isJPG && isLt1M;
    },
    handleAvatarSuccess(res,file,fileList){},
    handleAvatarSuccess1(res,file,fileList){},
  }
}
</script>
<style lang="stylus" scoped>

ul {
  list-style: none;
}
input {
  width: 99%;
  height: 39px;
  border: 1px solid rgba(0, 0, 0, 0.5);
  text-align: center;
  line-height: 40px;
  font-size: 20px;
  font-weight: bolder;
  background: white;
  color: red;
}

.createTop {
  width: 90%;
  height: 100%;
  margin: 0 auto;
}

.fontcolors {
  color: red;
}

.createLi {
  display: inline;
  line-height: 40px;
  width: 10.61%;
  float: left;
  border: 1px solid rgba(0, 0, 0, 0.5);
  text-align: center;
  font-size: 20px;
  font-weight: bolder;
  padding: 1px;
}

.fontSet {
  width: 100%;
  height: 76px;
  text-align: center;
  line-height: 76px;
  font-size: 20px;
  font-weight: bolder;
}

.marginCenter {
  margin: 0 auto;
  margin-top:10px;
}

.divBase {
  width: 100%;
  height: 300px;
  border: 1px solid red;
}

.showDataLi {
  width: 400px;
  height: 200px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: white;
  box-shadow: 0px 0px 8px rgba(216, 216, 216, 0.9);
  float: left;
  margin-left: 10px;
  margin-top: 10px;
  border-radius: 10px;
  overflow-y: hidden;
  cursor: pointer;
}

.showDataLi:hover {
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0px 0px 13px rgba(0, 0, 0, 0.3);
}

.showDataTop {
  width: 398px;
  height: 148px;
}

.showDataFoot {
  border-top: 1px solid rgba(216, 216, 216, 0.5);
  width: 100%;
  height: 51px;
  text-align: center;
  line-height: 50px;
  background: #F9FAFC;
  font-size: 14px;
  color: black;
}

.showDataFootLeft, .showDataFootRight {
  width: 50%;
  height: 51px;
  color: black;
  float: left;
  margin-left: 0px;
} 

.showDataFootLeft:hover, .showDataFootRight:hover {
  color: #03BC89;
  background: rgba(216, 216, 216, 0.4);
  font-weight: bolder;
}

.showDataFoot:hover {
    color: $theme-color;
    background: rgba(216, 216, 216, 0.4);
    font-weight: bolder;
}

.showDataTopLeft {
  border: 0px solid blue;
  width: 80px;
  height: 82px;
  float: left;
  margin-left: 10px;
  margin-top: 20px;
  border-radius: 42px;
  overflow-y: hidden;
}

.showDataImg {
  width: 100%;
  margin-top: -2px;
}

.showDataTopCenter {
  width: 210px;
  height: 100px;
  float: left;
  margin-left: 10px;
  margin-top: 20px;
}

.showDataTopRight {
  width: 80px;
  height: 148px;
  float: left;
  text-align: center;
}

.divTop {
  width: 100%;
}

.divfooter {
  width: 60%;
  height: 50px;
  margin-top:30px;
}
.statusGreen{
  width:50px;
  height:18px;
  font-size:10px;
  line-height:18px;
  color:white;
  background:#03BC89;
  margin:0px auto;
  margin-top:20px;
  border-radius: 10px;
}
.statusGray{
  width:50px;
  height:18px;
  font-size:10px;
  color:white;
  background:#B7B7B7;
  margin:0px auto;
  margin-top:20px;
  border-radius: 10px;
  line-height:18px;
}



  .checkBody-tag{
    width:50px;
    height:18px;
    font-size:10px;
    color:white;
    border-radius: 10px;
  }
</style>